package com.ruoyi.system.outto.goods.impl;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttributeMapper;
import com.ruoyi.system.V2.goodInfo.mapper.GoodsInfoImgMapper;
import com.ruoyi.system.V2.goodInfo.mapper.GoodsInfoMapper;
import com.ruoyi.system.V2.inter.mapper.ArtRecMapper;
import com.ruoyi.system.model.domain.ArtRec;
import com.ruoyi.system.model.domain.GameAttribute;
import com.ruoyi.system.model.domain.GoodsInfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.dto.GoodsInfoAndAttrValueDto;
import com.ruoyi.system.model.mapper.AccountInfoMapper;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.goods.NEWDDDSAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/8/16 22:58
 */
@Slf4j
@Service
public class NEWDDDSApiImpl implements NEWDDDSAPI {

    @Resource
    private CommonApi commonApi;
    @Value("${desc.title}")
    private String descTitle;

    @Resource
    private InfoImgMapper infoImgMapper;

    @Resource
    private AccountInfoMapper accountInfoMapper;
    @Resource
    private GoodsInfoMapper goodsInfoMapper;
    @Resource
    private GameAttributeMapper gameAttributeMapper;
    @Resource
    private ArtRecMapper artRecMapper;
    @Resource
    private GoodsInfoImgMapper goodsInfoImgMapper;

    @Override
    public AjaxResult addGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        Map<String, Object> resultMap = new HashMap<>();

        Map<String, Object> params = params(goodsInfoAndAttrValueDto, salePartner);
        log.info("担担代售添加接口请求参数={}", JSONObject.toJSONString(params));
        String result = HttpRequest.post("https://third-party.dandan365.com/tp/api/goods/sync/info").body(JSONObject.toJSONString(params)).execute().body();
        log.info("担担代售添加接口返回参数={}", result);
        JSONObject resultJson = JSONObject.parseObject(result);
        String data = resultJson.getString("data");
        if (!"1".equals(resultJson.getString("code"))){
            resultMap.put("code",500);
        }else {
            resultMap.put("code",200);
            ArtRec artRecreq = new ArtRec();
            artRecreq.setConfig(salePartner.getId());
            artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
            List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
            if(CollectionUtils.isNotEmpty(artRecs)) {
                artRecs.get(0).setOutid(String.valueOf(goodsInfoAndAttrValueDto.getId()));
                artRecMapper.updateArtRec(artRecs.get(0));
            }else{
                artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
                artRecreq.setCreateId(goodsInfoAndAttrValueDto.getCreateId());
                artRecreq.setType(LCConstant.interAdd);
                artRecreq.setConfig(salePartner.getId());
                artRecreq.setSaleCode(salePartner.getSaleName());
                artRecreq.setOutid(String.valueOf(goodsInfoAndAttrValueDto.getId()));
                artRecMapper.insertArtRec(artRecreq);
            }
        }
        resultMap.put("req",JSONObject.toJSONString(params));
        resultMap.put("res",result);
        resultMap.put("msg",resultJson.getString("data"));

        return AjaxResult.success(resultMap);
    }

    @Override
    public AjaxResult editGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto , SalePartner salePartner) {
        return addGame(goodsInfoAndAttrValueDto,salePartner);
    }

    @Override
    public AjaxResult delGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner sa) {
        Map<String, Object> resultMap = new HashMap<>();
        Map<String, Object> params = new TreeMap<>();
        params.put("appKey", sa.getSaleKey());
        String time = String.valueOf(System.currentTimeMillis());
        params.put("timestamp", time);
        String cover = sa.getSaleKey()+","+sa.getOther()+",123456,"+time;
        String sign = DigestUtils.md5Hex(cover);
        sign = sign+"123456";
        String string1 = DigestUtils.sha1Hex(sign);
        params.put("sign", string1);
        params.put("randStr", "123456");
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(sa.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        params.put("goodsId", artRecs.get(0).getOutid());

        log.info("担担代售删除接口请求参数={}", JSONObject.toJSONString(params));
        String result = HttpRequest.post("https://third-party.dandan365.com/tp/api/goods/sync/down").body(JSONObject.toJSONString(params)).execute().body();
        log.info("担担代售删除接口返回参数={}", result);


        JSONObject resultJson = JSONObject.parseObject(result);
        if (!"1".equals(resultJson.getString("code"))){
            resultMap.put("code",500);
        }else {
            resultMap.put("code",200);
        }
        resultMap.put("req",JSONObject.toJSONString(params));
        resultMap.put("res",result);
        resultMap.put("msg",resultJson.getString("data"));

        return AjaxResult.success(resultMap);
    }

    private Map<String, Object> params(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner sa) {

        Map<String, Object> params = new TreeMap<>();
        params.put("appKey", sa.getSaleKey());
        String time = String.valueOf(System.currentTimeMillis());
        params.put("timestamp", time);
        String cover = sa.getSaleKey()+","+sa.getOther()+",123456,"+time;
        String sign = DigestUtils.md5Hex(cover);
        sign = sign+"123456";
        String string1 = DigestUtils.sha1Hex(sign);
        params.put("sign", string1);
        params.put("randStr", "123456");

        params.put("goodsId", goodsInfoAndAttrValueDto.getId());
        String games = "[{\"gameId\":5,\"gameName\":\"原神\",\"cateTags\":null},{\"gameId\":11,\"gameName\":\"崩坏星穹铁道\",\"cateTags\":null},{\"gameId\":9,\"gameName\":\"王者荣耀\",\"cateTags\":null},{\"gameId\":3,\"gameName\":\"无畏契约\",\"cateTags\":null},{\"gameId\":10,\"gameName\":\"和平精英\",\"cateTags\":null},{\"gameId\":31,\"gameName\":\"三角洲行动\",\"cateTags\":null},{\"gameId\":4,\"gameName\":\"三国杀移动版\",\"cateTags\":null},{\"gameId\":15,\"gameName\":\"绝区零\",\"cateTags\":null},{\"gameId\":19,\"gameName\":\"火影忍者\",\"cateTags\":null},{\"gameId\":6,\"gameName\":\"英雄联盟\",\"cateTags\":null},{\"gameId\":32,\"gameName\":\"瓦罗兰特\",\"cateTags\":null},{\"gameId\":8,\"gameName\":\"穿越火线\",\"cateTags\":null},{\"gameId\":12,\"gameName\":\"穿越火线枪战王者\",\"cateTags\":null},{\"gameId\":21,\"gameName\":\"命运方舟\",\"cateTags\":null},{\"gameId\":7,\"gameName\":\"永劫无间\",\"cateTags\":null},{\"gameId\":29,\"gameName\":\"阴阳师\",\"cateTags\":null},{\"gameId\":37,\"gameName\":\"光遇\",\"cateTags\":null},{\"gameId\":20,\"gameName\":\"DNF手游\",\"cateTags\":null},{\"gameId\":33,\"gameName\":\"蛋仔派对\",\"cateTags\":null},{\"gameId\":22,\"gameName\":\"三国杀十周年\",\"cateTags\":null},{\"gameId\":17,\"gameName\":\"明日方舟\",\"cateTags\":null},{\"gameId\":36,\"gameName\":\"QQ飞车手游\",\"cateTags\":null},{\"gameId\":28,\"gameName\":\"尘白禁区\",\"cateTags\":null},{\"gameId\":24,\"gameName\":\"地下城与勇士\",\"cateTags\":null},{\"gameId\":38,\"gameName\":\"英雄联盟手游\",\"cateTags\":null},{\"gameId\":13,\"gameName\":\"鸣潮\",\"cateTags\":null},{\"gameId\":16,\"gameName\":\"金铲铲之战\",\"cateTags\":null},{\"gameId\":34,\"gameName\":\"逆水寒手游\",\"cateTags\":null},{\"gameId\":23,\"gameName\":\"三国杀OL\",\"cateTags\":null},{\"gameId\":26,\"gameName\":\"绝地求生\",\"cateTags\":null},{\"gameId\":14,\"gameName\":\"使命召唤手游\",\"cateTags\":null},{\"gameId\":35,\"gameName\":\"QQ飞车\",\"cateTags\":null},{\"gameId\":25,\"gameName\":\"部落冲突\",\"cateTags\":null},{\"gameId\":30,\"gameName\":\"APEX英雄\",\"cateTags\":null},{\"gameId\":27,\"gameName\":\"暗区突围\",\"cateTags\":null}]\n";
        JSONArray jsonArray = JSONArray.parseArray(games);
        for(Object o : jsonArray){
            if(JSONObject.parseObject(o.toString()).getString("gameName").replace("穿越火线枪战王者","枪战王者")
                   .equals(goodsInfoAndAttrValueDto.getGameName().replace("英雄联盟(手游)","英雄联盟手游"))){
                params.put("gameId", JSONObject.parseObject(o.toString()).getString("gameId"));
                break;
            }
        }
        params.put("account", goodsInfoAndAttrValueDto.getAccountNumber());
        params.put("password", System.currentTimeMillis());
        params.put("phone", "18888888888");
        params.put("cost", goodsInfoAndAttrValueDto.getPrice().intValue()*100);
        params.put("salePrice", goodsInfoAndAttrValueDto.getPrice().intValue()*100);
        params.put("advantage", goodsInfoAndAttrValueDto.getDes().length()>4900?goodsInfoAndAttrValueDto.getDes().substring(0,4900):goodsInfoAndAttrValueDto.getDes());
        GoodsInfoImg goodsInfoImg = new GoodsInfoImg();
        goodsInfoImg.setGoodsId(goodsInfoAndAttrValueDto.getId());
        goodsInfoImg.setType(Constants.STR_1);
        List<GoodsInfoImg> infoImgs = goodsInfoImgMapper.selectGoodsInfoImgList(goodsInfoImg);
        List<String> collect = infoImgs.stream().map(img -> img.getImgUrl()).collect(Collectors.toList());
        params.put("snapshots", collect);
        JSONObject goodsPictureMap = new JSONObject();
        goodsPictureMap.put("1",new String[]{goodsInfoAndAttrValueDto.getTitleImg()});
        goodsPictureMap.put("2",new String[]{goodsInfoAndAttrValueDto.getTitleImg()});
        JSONObject extAttrMap = new JSONObject();
        params.put("goodsPictureMap", goodsPictureMap);
        List tagIds = new ArrayList();
        if(goodsInfoAndAttrValueDto.getGameName().equals("王者荣耀")){
            extAttrMap.put("heroNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF7())?goodsInfoAndAttrValueDto.getF7():"0");
            extAttrMap.put("skinNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF8())?goodsInfoAndAttrValueDto.getF8():"0");
            String attr = getAttr("9",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1){
                if(JSONObject.parseObject(o.toString()).getString("name").equals("渠道")){
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    String regional = goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName();
                    for(Object p : jsonArray2){
                        if(JSONObject.parseObject(p.toString()).getString("tagName").equals(regional)){
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("实名修改")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF16())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF16()));
                        if(gameAttribute1.getFieldName().equals("可二次实名")){
                            tagIds.add("2249");
                        }else {
                            tagIds.add("2250");
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("防沉迷")){
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for(Object p : jsonArray2) {
                        if(JSONObject.parseObject(p.toString()).getString("tagName").equals("没有")){
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("实名人")){
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for(Object p : jsonArray2) {
                        if(JSONObject.parseObject(p.toString()).getString("tagName").equals("是本人")){
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("贵族等级")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(Object p : jsonArray2) {
                            if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                break;
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("可否排位")){
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for(Object p : jsonArray2) {
                        if(JSONObject.parseObject(p.toString()).getString("tagName").equals("可以")){
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("荣耀典藏")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF9())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF9());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().replace("-","").equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("荣耀典藏")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF9())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF9());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().replace("-","").equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("星元皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF10())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF10());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().replace("-","").equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("无双皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF21())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF21());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().replace("-","").equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("传说皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF12());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().replace("-","").equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("史诗皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().replace("-","").equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        if(goodsInfoAndAttrValueDto.getGameName().equals("和平精英")){
            extAttrMap.put("VehicleNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF7())?goodsInfoAndAttrValueDto.getF7():"0");
            extAttrMap.put("PinkNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())?goodsInfoAndAttrValueDto.getF11():"0");
            extAttrMap.put("SpecialeffectsNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())?goodsInfoAndAttrValueDto.getF12():"0");
            extAttrMap.put("setsNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF8())?goodsInfoAndAttrValueDto.getF8():"0");
            extAttrMap.put("gunsNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF9())?goodsInfoAndAttrValueDto.getF9():"0");
            extAttrMap.put("imprintsNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF16())?goodsInfoAndAttrValueDto.getF16():"0");
            String attr = getAttr("27",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1) {
                if (JSONObject.parseObject(o.toString()).getString("name").equals("渠道")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").contains(goodsInfoAndAttrValueDto.getCarrierName())) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("飞行器")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF3());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("飞行器")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF3());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("实名修改")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF10())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF10()));
                        if(gameAttribute1.getFieldName().equals("可二次实名")){
                            tagIds.add("1784");
                        }else {
                            tagIds.add("1786");
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("实名人")){
                    tagIds.add("1787");
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("防沉迷")){
                    tagIds.add("1789");
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("优质套装")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF5());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("紫色套装")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF5());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("载具")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF2());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("稀有枪皮")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF1())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF1());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        if(goodsInfoAndAttrValueDto.getGameName().equals("枪战王者")){
            extAttrMap.put("heroarmsNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())?goodsInfoAndAttrValueDto.getF5():"0");
            extAttrMap.put("KingNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF4())?goodsInfoAndAttrValueDto.getF4():"0");
            String attr = getAttr("12",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1) {
                if (JSONObject.parseObject(o.toString()).getString("name").equals("渠道")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").equals(regional)) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("实名修改")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF10())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF10()));
                        if(gameAttribute1.getFieldName().equals("可修改实名")){
                            tagIds.add("6389");
                        }else {
                            tagIds.add("6388");
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("VIP等级")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(Object p : jsonArray2) {
                            if(JSONObject.parseObject(p.toString()).getString("tagName").replace("IP","").equals(gameAttribute1.getFieldName())){
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("至尊系列")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF12());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("王者系列")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF15())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF15());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("热门武器")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF16())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF16());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("角色")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF8())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF8());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        if(goodsInfoAndAttrValueDto.getGameName().equals("英雄联盟")){
            extAttrMap.put("skinsNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF4())?goodsInfoAndAttrValueDto.getF4():"0");
            extAttrMap.put("heroNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())?goodsInfoAndAttrValueDto.getF3():"0");
            extAttrMap.put("MythsNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF18())?goodsInfoAndAttrValueDto.getF18():"0");
            extAttrMap.put("ZhencaiNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF23())?goodsInfoAndAttrValueDto.getF23():"0");
            extAttrMap.put("ColorfulNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())?goodsInfoAndAttrValueDto.getF5():"0");
            String attr = getAttr("6",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1) {
                if (JSONObject.parseObject(o.toString()).getString("name").equals("服务器")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").contains(goodsInfoAndAttrValueDto.getGroupName())) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("区服")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").contains(goodsInfoAndAttrValueDto.getServerName())) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("实名修改")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF1())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF1()));
                        if(gameAttribute1.getFieldName().equals("可修改实名")){
                            tagIds.add("1585");
                        }else {
                            tagIds.add("1586");
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("单双排段位")) {
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (Object p : jsonArray2) {
                            if (JSONObject.parseObject(p.toString()).getString("tagName").contains(gameAttribute1.getFieldName())) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                break;
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("至臻皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF8())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF8());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("臻彩皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF24())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF24());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("年限皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF10())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF10());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("海克斯皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF9())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF9());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("情人节限定")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF12());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("冰雪限定")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF13())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF13());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("终极皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF17());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("神话皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF26())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF26());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        if(goodsInfoAndAttrValueDto.getGameName().equals("英雄联盟(手游)")){
            extAttrMap.put("skinNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF6())?goodsInfoAndAttrValueDto.getF6():"0");
            extAttrMap.put("heroNum", StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())?goodsInfoAndAttrValueDto.getF5():"0");
            String attr = getAttr("38",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1) {
                if (JSONObject.parseObject(o.toString()).getString("name").equals("渠道")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    String regional = goodsInfoAndAttrValueDto.getSystemName() + goodsInfoAndAttrValueDto.getCarrierName();
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").equals(regional)) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("实名修改")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF4())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF4()));
                        if (gameAttribute1.getFieldName().equals("可二次实名")) {
                            tagIds.add("12500");
                        } else {
                            tagIds.add("12501");
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("防沉迷")) {
                    tagIds.add("12502");
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("段位")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (Object p : jsonArray2) {
                            if (gameAttribute1.getFieldName().contains(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                break;
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("传说皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF2());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("典藏皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF10())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF10());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("神话皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF9())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF9());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        if(goodsInfoAndAttrValueDto.getGameName().equals("永劫无间")){
            String attr = getAttr("7",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1) {
                if (JSONObject.parseObject(o.toString()).getString("name").equals("渠道")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").toUpperCase().contains(goodsInfoAndAttrValueDto.getGroupName().toUpperCase())) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("远程武器金皮")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF38())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF38());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("飞索皮肤")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF23())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF23());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("是否绑定手游")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF55())) {
                        GameAttribute gameAttribute11 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF55()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (Object p : jsonArray2) {
                            if (gameAttribute11.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("换绑冷却")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF54())) {
                        GameAttribute gameAttribute11 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF54()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (Object p : jsonArray2) {
                            if (gameAttribute11.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("网易支付状态")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF50())) {
                        GameAttribute gameAttribute11 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF50()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (Object p : jsonArray2) {
                            if (gameAttribute11.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("谪星皮肤")){
                    String pfIds = "";
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF2());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF3());
                    List<GameAttribute> gameAttributes = getGameAttributs(pfIds);
                    if(CollectionUtils.isNotEmpty(gameAttributes)) {
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributes) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("角色金皮")){
                    String pfIds = "";
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF4());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF5());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF6());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF7());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF8());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF9());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF10());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF11());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF12());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF13());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF14());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF15());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF16());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF17());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF18());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF19());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF20());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF21());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF22());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF44());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF53());
                    List<GameAttribute> gameAttributes = getGameAttributs(pfIds);
                    if(CollectionUtils.isNotEmpty(gameAttributes)) {
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributes) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("近战武器金皮")){
                    String pfIds = "";
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF24());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF25());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF26());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF27());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF42());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF43());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF28());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF32());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF33());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF34());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF35());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF37());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF45());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF52());
                    List<GameAttribute> gameAttributes = getGameAttributs(pfIds);
                    if(CollectionUtils.isNotEmpty(gameAttributes)) {
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributes) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        if(goodsInfoAndAttrValueDto.getGameName().equals("永劫无间手游")){
            String attr = getAttr("7",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1) {
                if (JSONObject.parseObject(o.toString()).getString("name").equals("渠道")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").contains(goodsInfoAndAttrValueDto.getCarrierName())) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("发型")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF26())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF26());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("饰品")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF27())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF27());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("换绑冷却")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF35())) {
                        GameAttribute gameAttribute11 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF35()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (Object p : jsonArray2) {
                            if (gameAttribute11.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("是否绑定端游")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF23())) {
                        GameAttribute gameAttribute11 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF23()));
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (Object p : jsonArray2) {
                            if (gameAttribute11.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("飞索皮肤")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF15())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF15());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        if(goodsInfoAndAttrValueDto.getGameName().equals("暗区突围")){
            String attr = getAttr("27",sa);
            String data = JSONObject.parseObject(attr).getString("data");
            String cateTags = JSONObject.parseObject(data).getString("cateTags");
            JSONArray jsonArray1 = JSONArray.parseArray(cateTags);
            for(Object o : jsonArray1) {
                if (JSONObject.parseObject(o.toString()).getString("name").equals("渠道")) {
                    String tags = JSONObject.parseObject(o.toString()).getString("tags");
                    JSONArray jsonArray2 = JSONArray.parseArray(tags);
                    for (Object p : jsonArray2) {
                        if (JSONObject.parseObject(p.toString()).getString("tagName").contains(goodsInfoAndAttrValueDto.getCarrierName())) {
                            tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                            break;
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("大金")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF12());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("小金")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF13())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF13());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("皮肤")){
                    String pfIds = "";
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF6());
                    pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF8());
                    List<GameAttribute> gameAttributes = getGameAttributs(pfIds);
                    if(CollectionUtils.isNotEmpty(gameAttributes)) {
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for(GameAttribute gameAttribute1 : gameAttributes) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("实名修改")){
                    if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                        GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                        if(gameAttribute1.getFieldName().equals("可二次实名")){
                            tagIds.add("8038");
                        }else {
                            tagIds.add("8039");
                        }
                    }
                }
                if(JSONObject.parseObject(o.toString()).getString("name").equals("防沉迷")){
                    tagIds.add("8040");
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("手套")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF7())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF7());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
                if (JSONObject.parseObject(o.toString()).getString("name").equals("近战武器")) {
                    if (StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF9())) {
                        List<GameAttribute> gameAttributs = getGameAttributs(goodsInfoAndAttrValueDto.getF9());
                        String tags = JSONObject.parseObject(o.toString()).getString("tags");
                        JSONArray jsonArray2 = JSONArray.parseArray(tags);
                        for (GameAttribute gameAttribute1 : gameAttributs) {
                            for (Object p : jsonArray2) {
                                if (gameAttribute1.getFieldName().equals(JSONObject.parseObject(p.toString()).getString("tagName"))) {
                                    tagIds.add(JSONObject.parseObject(p.toString()).getString("tagId"));
                                }
                            }
                        }
                    }
                }
            }
        }
        params.put("extAttrMap", extAttrMap);
        if(CollectionUtils.isNotEmpty(tagIds)){
            params.put("tagIds", tagIds);
        }
        return params;
    }

    public static void main(String[] args) {
        SalePartner salePartner = new SalePartner();
        salePartner.setSaleKey("s70q1u3ecmdr");
        salePartner.setOther("0caa7bc833517b73934958d7d71000be");
        String area = getAttr("10",salePartner);
        System.out.println(area);
    }

    static String getGames(){
        Map<String, String> params = new TreeMap<>();
        String string = "https://third-party.dandan365.com/tp/api/game/query/queryAllGame";
        params.put("appKey", "s70q1u3ecmdr");
        String time = String.valueOf(System.currentTimeMillis());
        params.put("timestamp", time);
        String cover = "s70q1u3ecmdr,0caa7bc833517b73934958d7d71000be,123456,"+time;
        String sign = DigestUtils.md5Hex(cover);
        sign = sign+"123456";
        String string1 = DigestUtils.sha1Hex(sign);
        params.put("sign", string1);
        params.put("randStr", "123456");
        String body = HttpRequest.post(string).body(JSONObject.toJSONString(params)).execute().body();
        return body;
    }

    static String getAttr(String gameId, SalePartner salePartner){
        Map<String, String> params = new TreeMap<>();
        String string = "https://third-party.dandan365.com/tp/api/game/query/queryGameWithCateTag";
        params.put("appKey", salePartner.getSaleKey());
        String time = String.valueOf(System.currentTimeMillis());
        params.put("timestamp", time);
        String cover = salePartner.getSaleKey()+","+salePartner.getOther()+",123456,"+time;
        String sign = DigestUtils.md5Hex(cover);
        sign = sign+"123456";
        String string1 = DigestUtils.sha1Hex(sign);
        params.put("sign", string1);
        params.put("randStr", "123456");
        params.put("gameId", gameId);
        String body = HttpRequest.post(string).body(JSONObject.toJSONString(params)).execute().body();
        return body;
    }

    private String reIds(String allIds, String ids) {
        if (StringUtils.isNotEmpty(ids)) {
            if (StringUtils.isNotEmpty(allIds)) {
                allIds = allIds + "," + ids;
            } else {
                allIds = ids;
            }
        }
        return allIds;
    }

    private List<GameAttribute> getGameAttributs(String ids) {
        if (StringUtils.isEmpty(ids)) {
            return new ArrayList<>();
        }
        return gameAttributeMapper.selectGameAttributeListByIds((Long[]) ConvertUtils.convert(ids.split(","),
                Long.class));
    }

}
